﻿@model Verano.Models.Morador

@{
    ViewBag.Title = "Edit";
}

<h2>Editar</h2>

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.maskedinput-1.3.min.js")" type="text/javascript"></script>

<script language="javascript">
    $(document).ready(function () {

        $("#Cpf").mask("999.999.999-99");
        $("#DataNascimento").mask("99/99/9999");
        $("#Celular").mask("9999-9999");

        $('#IdPredio').change(function () {

            var params = { id: $(this).val() };

            $.ajax({
                url: '/Apartamento/CarregarCombo',
                type: 'POST',
                data: JSON.stringify(params),
                dataType: 'json',
                contentType: 'application/json; charset=utf-8',
                success: function (data) {

                    $('#IdApartamento').empty();

                    for (var i = 0; i < data.length; i++) {
                        $('#IdApartamento').append('<option value="' + data[i].Id + '">' + data[i].Numero + '</option>');
                    }
                },
                error: function () { }
            });
        });

    });
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Morador</legend>

        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.DataCadastro)

        <input type="hidden" name="Login" value="@User.Identity.Name" />

        <div class="editor-label">
            <label>Nome</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Nome)
            @Html.ValidationMessageFor(model => model.Nome)
        </div>

        <div class="editor-label">
            <label>Sobrenome</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Sobrenome)
            @Html.ValidationMessageFor(model => model.Sobrenome)
        </div>

        <div class="editor-label">
            <label>CPF</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Cpf)
            @Html.ValidationMessageFor(model => model.Cpf)
        </div>

        <div class="editor-label">
            <label>Data de Nascimento</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DataNascimento)
            @Html.ValidationMessageFor(model => model.DataNascimento)
        </div>

        <div class="editor-label">
            <label>E-mail</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            <label>Celular</label>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Celular)
            @Html.ValidationMessageFor(model => model.Celular)
        </div>

        <div class="editor-field">
            <label>Bloco</label>
            @Html.DropDownList("IdPredio")
            <label>Bloco</label>
            @Html.DropDownList("IdApartamento", string.Empty)
            @Html.ValidationMessageFor(model => model.IdApartamento)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagDisponivel)
            <label>Se dispõe a ajudar o condomínio</label>
            @Html.ValidationMessageFor(model => model.FlagDisponivel)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagConselheiro)
            <label>Participa do conselho</label>
            @Html.ValidationMessageFor(model => model.FlagConselheiro)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagDeficiente)
            <label>Possui deficiência Física</label>
            @Html.ValidationMessageFor(model => model.FlagDeficiente)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagFumante)
            <label>É Fumante</label>
            @Html.ValidationMessageFor(model => model.FlagFumante)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagProprietario)
            <label>É o proprietário do apartamento</label>
            @Html.ValidationMessageFor(model => model.FlagProprietario)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.FlagPraticaEsporte)
            <label>Pratica esporte</label>
            @Html.ValidationMessageFor(model => model.FlagPraticaEsporte)
        </div>

        <p>
            <input type="submit" value="Atualizar" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Voltar", "Index")
</div>
